package design.command;
import design.book.*;
public class Controller { //命令模式
	private AbstractCommand add,searchone,searchall,sortbyprice,delete,modify,write,read;
	public Controller(AbstractCommand add,AbstractCommand searchone,AbstractCommand searchall, 
					  AbstractCommand sortbyprice,AbstractCommand modify, AbstractCommand delete, AbstractCommand write, AbstractCommand read) {
		this.add = add;
		this.searchone = searchone;
		this.searchall = searchall;
		this.modify = modify;
		this.sortbyprice = sortbyprice;
		this.delete = delete;
		this.write = write;
		this.read = read;
	}
	
	public void add(Book b){
		add.preproessing(b);
	}
	
	public void searchone(String attribute){
		searchone.execute(attribute);
	}
	
	public void searchall(String attribute){
		searchall.execute(attribute);
	}
	
	public void modify(String attribute){
		modify.execute(attribute);
	}
	
	public void delete(String attribute){
		delete.execute(attribute);
	}
	
	public void sortbyprice(String attribute){
		sortbyprice.execute(attribute);
	}
	
	public void writetofile(String attribute){
		write.execute(attribute);
	}
	
	public void readfromfile(String attribute){
		read.execute(attribute);
	}
}
